package com.gitee.aurora.server.service.impl;

import com.gitee.aurora.server.dao.RulesLogResultDao;
import com.gitee.aurora.server.service.RulesLogResultService;
import com.gitee.aurora.server.vo.RulesLogResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class RulesLogResultServiceImpl implements RulesLogResultService {
    @Autowired
    private RulesLogResultDao resultDao;

    @Override
    public List<RulesLogResultVo> queryRulesLogResultList(RulesLogResultVo rulesLogResultVo) {
        RulesLogResultVo rulesLogRes =new RulesLogResultVo();
        List list =new ArrayList();

        if (rulesLogResultVo==null){
            return new ArrayList<>();
        }
        if (rulesLogResultVo.getCode()==null){
            return new ArrayList<>();
        }
        String [] s= rulesLogResultVo.getCode().split(",");
        Arrays.stream(s).iterator().forEachRemaining(x->{
            rulesLogRes.setCode(x);
            rulesLogRes.setTablename(rulesLogResultVo.getTablename());
            list.add(resultDao.queryMaxRulesLogResultSj(rulesLogRes).get(0).getInserttime());
        });
        rulesLogResultVo.setList(list);
        return resultDao.queryRulesLogResultList(rulesLogResultVo);
    }


}
